
import React from 'react';
import { Modal, Button,Form,Input,Table,Col } from 'antd';
import * as Utils from "../../utils/action";
import TextArea from 'antd/lib/input/TextArea';
class BasicModal extends React.Component {
  state = {
    inputValue:'',
    tableData:[]
  };
  componentDidMount() {
    this.props.onRef(this);
  }
  componentWillReceiveProps(nextProps){
    if(nextProps){
      this.setState({
        tableData:nextProps.data
      })
    }
  }
  
  inputChange=(e)=>{
    this.setState({inputValue:e.target.value})
  }
  modalSubmit=()=>{
    this.props.modalSubmit();
  }

  closeModal = () => {
    const p = this;
    const { onCancel } = p.props;
    // form.resetFields();
    onCancel();
  };
      
  
  render(){
    const p = this;
    const { visible, title,width,column,data } = this.props;
    const modalProps = {
      title,
      visible,
      width,
      onCancel() {
        p.closeModal();
      },
      okText:'保存',
      cancelText:'取消',
      onOk(){
        p.modalSubmit();
      }
    };

    return(
      <Modal {...modalProps}>
         <div style={{width:'100%',display:'flex',marginBottom:'1rem'}}><span style={{width:'10%'}}>备注:</span><TextArea onChange={this.inputChange}/></div>
                <Table columns={column} dataSource={p.state.tableData}/>
       </Modal>
    )
  }
}


export default Form.create({})(BasicModal);
